package demo.gui;

import static org.lwjgl.opengl.GL11.*;
import org.lwjgl.util.glu.Sphere;

import engine.gameObject.GameObject;
import engine.gameObject.camera.FlyoverCamera;
import engine.light.EnvironmentLight;
import engine.loader.texture.TextureLoader;
import engine.scene.Scene;

public class LobbyScene extends Scene{

	public LobbyScene(String name) {
		super(name);
	}
	
	@Override
	public void init() {
		
		//camera
		setCurrentCamera(new FlyoverCamera());
		getCurrentCamera().setNearPane(100);
		
		//a simple static object. 
		GameObject s1 = new GameObject() {
			@Override
			public void render(float timeElapsed) {
				glColor3f(0, 1, 0);
				new Sphere().draw(4, 10, 10);
			}
		};
		s1.setBounds(0, 0, 0, 4);
		s1.setPosition(0, 10, 0);
		
		addGameObject(s1);
		
		GameObject s3 = new GameObject() {
			@Override
			public void render(float timeElapsed) {
				glColor3f(0, 0, 1);
				new Sphere().draw(4, 10, 10);
			}
		};
		s3.setBounds(0, 0, 0, 4);
		s3.setPosition(-10, -10, -10);
		
		addGameObject(s3);
		
		//a sky object
		GameObject s2 = new GameObject() {
			int tex = TextureLoader.loadTexture("test/sky.png");
			Sphere s = new Sphere();
			
			@Override
			public void render(float timeElapsed) {
				glColor4f(1, 1, 1, 1);
				s.setTextureFlag(true);
				glEnable(GL_TEXTURE_2D);
				glBindTexture(GL_TEXTURE_2D, tex);
				
				s.draw(11, 10, 10);
				
				glDisable(GL_TEXTURE_2D);
			}
		};
		setSkyObject(s2);
		
		//a dynamic object
		TestObject p = new TestObject();
		addGameObject(p);
		
		EnvironmentLight light = new EnvironmentLight();
		light.setAmbient(0.3f, 0.3f, 0.3f);
		light.setDirection(-1, 1, -1);
		light.setDiffuse(0.5f, 0.5f, 0.5f);
		addLight(light);
	}
}
